package com.study.talk.utils

import android.app.ActivityManager
import android.content.Context
import android.content.res.Configuration
import android.util.Log

object ActivityUtil {
    private const val TAG = "ActivityUtil"
    fun topName(context: Context): String {
        val manager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
        val appTasks = manager.getRunningTasks(1)
        if (appTasks != null) {
            Log.d(TAG, "getTopActivityName: " + appTasks[0].topActivity?.className)
            return appTasks[0].topActivity!!.className
        } else return ""
    }

    fun isPad(context: Context): Boolean {
        return ((context.resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE)
    }
}
